﻿/*** This script will only run if the version number in the database is less than 01.60.00 ***/
if((SELECT REPLACE(VersionNumber,'.','') FROM Version) < '016000')
BEGIN

/****** Object:  Table [dbo].[SilverlightDesktopInstance] ******/
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SilverlightDesktopInstance]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[SilverlightDesktopInstance](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[DesktopName] [nvarchar](50) NOT NULL,
	[DesktopSizeHorizontal] [int] NOT NULL,
	[DesktopSizeVertical] [int] NOT NULL,
	[Transparent] [bit] NOT NULL,
	[ShowToolbar] [bit] NOT NULL,
	[AutoLoadModule] [int] NOT NULL,
 CONSTRAINT [PK_SilverlightDesktopInstances] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END

/****** Object:  Table [dbo].[SilverlightDesktopInstanceModules] ******/
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SilverlightDesktopInstanceModules]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[SilverlightDesktopInstanceModules](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[InstanceID] [int] NOT NULL,
	[ModuleID] [int] NOT NULL,
 CONSTRAINT [PK_SilverlightDesktopInstanceModules] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
	
	/** Update Version **/
	DELETE FROM Version
	INSERT INTO Version(VersionNumber) VALUES (N'01.60.00')

END